This is a creation in
Article, where the information may have evolved or changed.
[TOC]
Description
This article requires more than 1.5 cross-compiling
Golang MAC to compile Windows 64
➜ ~CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o test_win_x64.exe test.go
Linux 64 support under Golang MAC
➜ ~CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o test_linux_x64 test.go
Prepare a cross-compilation envir
Recently, to the internal network for debugging and access, bought 3 peanuts can only map 6 ports, is not enough to meet the needs, just have a friend to me said Ngrok can also be carried through the intranet, research for a few days, light installation will kill a gang of people, fortunately found on the GitHub a button to install Ngrok footsteps, Let's share them first.System: CentOS 6.x (64-bit)
Script content:Cat ngrok.sh
#!/bin/bash#-*-Coding:utf-8-*-
# Get the current script execution p
-compilation tool chain
The > Cross-compilation toolchain is a comprehensive development environment consisting of compilers, connectors, and interpreters, and the cross-compilation toolchain consists of 3 parts, binutils, GCC, and glibc.
> Sometimes in order to reduce the size of the LIBC library, other C libraries can be used instead of glibc, such as UCLIBC, DIETLIBC, and Newlib.
Cross-platform cross-compilation of Golang
The go language is a compiled language that allows programs to be compi
Library construction always have to face the problem.
Parameters for cross-construction
After Go1.6 added support for building C static libraries, cross-compiling is also very simple and only needs to be set up GOARCH and GOOS on the line.
Because GOOS there is only Darwin one type of iOS, we just need to set GOARCH it up.
To build a C static library, we need to put the above MyStrDup implementation into a
which platform's content, we need to compile the target platform's tool chain. Let's take a look at some of the environment parameters shown in the Go Env run.
Here the Goarch and GOOS distribution represents the architecture and OS information for the target platform, Gohostarch and Gohostos represent the host's architecture and OS information.
Because we are in the MAC environment, now Gohostarch is Amd64,gohostos is Darwin, this is the same; the
Golang supports the ability to generate cross-compilation of another platform executable program under one platform.Linux under Mac, 64-bit executable program for Windows platform:1 cgo_enabled=0 goos=linux goarch=amd64 go build [Application | gofile.go]2 cgo_ enabled=0 goos=windows goarch=amd64 go build [Application | gofile.go]Linux under Compile Mac, Windows platform 64-bit executable:1 cgo_enabled=0 goo
This is a creation in
Article, where the information may have evolved or changed.
Golang Support cross-compilation, on one platform to generate another platform executable program, recently used, very useful, here is a memo.
Linux and Windows 64-bit executables are compiled under MAC
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build main.goCGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build main.go
Linux under
This is a creation in
Article, where the information may have evolved or changed.
1, environment variable Golang official website Introduction
$GOROOT
the root of the Go tree, often
$HOME/go . This defaults to the parent of the directory where is
all.bash run. If you choose not to set
$GOROOT , you must run
gomake instead of
make or when
gmake developing Go programs using the Conventional makefiles.
$GOROOT_FINAL
The value assumed by installed bi
some of the environment parameters shown in the Go Env run.Here the Goarch and GOOS distribution represents the architecture and OS information for the target platform, Gohostarch and Gohostos represent the host's architecture and OS information.Because we are in the MAC environment, now Gohostarch is Amd64,gohostos is Darwin, this is the same; the default Goarch and GOOS are native platforms, we want to c
Install, configure, upgrade, and uninstall 82682171 Linux go78525639 CentOS installation Golang, protobufhttps://www.cnblogs.com/mrblue/p/8891789.html CentOS7 Install GO environmenthttps://www.cnblogs.com/pyyu/p/8032257.html Go language Commentary goroot, Gopath, GOBINHTTPS://HK.SAOWEN.COM/A/0974F14EBEAACEFC2D4EA7193121F6FAF8304388ACC206E1781D42781D3883AF Golang using the Protobuf tutorial53788067 Golang How to cross-compile in Mac, Linux, Windows1 Golang Support cross-compilation, on one platfo
This is a created
article in which the information may have evolved or changed.
Golang supports cross-compilation and generates an executable program for another platform on one platform
Linux and Windows 64-bit executables are compiled under MAC
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build main.goCGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build main.go
Linux under Compile Mac and Windows 64-bit exec
/install/source
$GOROOT the root of the Go tree, often $HOME/go1. X. Its value are built into the tree when it's compiled, and defaults to the parent of the directory where All.bash was RU N. There is no need to set this unless you want to switch between multiple local copies of the repository. $GOROOT _final The value assumed by installed binaries and scripts when $GOROOT are not set explicitly. It defaults to the value of $GOROOT. If you want to build the Go tree on one location but move it
People familiar with Golang know that Golang cross-compiling is very simple, just set up a few environment variables can be
# mac上编译linux和windows二进制CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build # linux上编译mac和windows二进制CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build CGO_ENABLED=0 GOOS=windows
This is a creation in
Article, where the information may have evolved or changed.
Turn from "http://blog.csdn.net/panshiqu/article/details/53788067"
Golang Support cross-compilation, on one platform to generate another platform executable program, recently used, very useful, here is a memo.
Linux and Windows 64-bit executables are compiled under MAC
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build main.goCGO_ENABLED=0 GOOS=windows
This is a created
article in which the information may have evolved or changed.
Go is a compiled language, so on different platforms, you need to compile and generate binary packages of different formats.
Because go 1.5 has some improvements to cross-platform compilation, including a unified compiler, linker, and so on.Compile time only need to specify two parameters: GOOS and GOARCH can.
Example:
# 编译到 linux 64bit$ GOOS=linux
Execute binary file
And what can we do?
Cross-compilation
Go 1.5 has excellent out-of-the-box and cross compilation capabilities, so if your container OS and/or architecture doesn't match your system, it's not a problem!
To turn on cross compilation, you need to set up GOOS and/or Goarch.
For example, suppose on a 64-bit Mac:
Docker run-e goos=darwin-e goarch=amd64-v/tmp/crosstest:/go/bin \Golang Go
://studygolang.com/articles/12615)-[Golang's pros and cons of DevOps development (six): Cross-platform compilation, Windows,signals,docs and compilers] (https:// studygolang.com/articles/12616)-The pros and cons of Golang for DevOps development (six part Six): Version control for Defer directives and package dependencies # Golang: Compiling Windows programs under Linux for me this For those of you who are primarily using Linux, I feel a great deal of pain when I occasionally have to cope with pr
This is a creation in
Article, where the information may have evolved or changed.
GOOS: The operating system of the target platform (Darwin, FreeBSD, Linux, Windows)Goarch: Architecture of the target platform (386, AMD64, ARM)
Linux and Windows 64-bit executables are compiled under MAC
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build CGO_ENABLED=0 GOOS=windows GOARCH
release version.
2.1.2 Download Go
Go Use the Mercurial version Management system to manage the code. If you do not have Mercurial, you can download it from the Mercurial official website (http://mercurial.selenic.com/) .
Linux under platform, install with the following command:
$ sudo easy_install Mercurial
Window can be used under the platform Tortoisehg .
Make sure that GOROOT there is no or empty directory. Then check out the code from the warehouse:
$ HG Clone-r Release Https://go.goog
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.